home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / HIPTRIG.QC < prev    next >
Text File  |  1997-02-05  |  6KB  |  283 lines

  1. /* Trigger QuickC program
  2.    By Jim Dose'  12/2/96
  3.    Copyright (c)1996 Hipnotic Interactive, Inc.
  4.    All rights reserved.
  5.    Do not distribute.
  6. */
  7.  
  8. float USE_GOLD_KEY = 1;
  9.  
  10. void() keytrigger_use =
  11.    {
  12.    if (activator.classname != "player")
  13.         return;
  14.    if (self.attack_finished > time)
  15.         return;
  16.  
  17.    self.attack_finished = time + 2;
  18.  
  19. // FIXME: blink key on player's status bar
  20.    if ( (self.items & activator.items) != self.items )
  21.       {
  22.       if (self.message != "")
  23.          {
  24.          centerprint (activator, self.message);
  25.          }
  26.       else
  27.          {
  28.          if (self.owner.items == IT_KEY1)
  29.             {
  30.             if (world.worldtype == 2)
  31.                {
  32.                centerprint (activator, "You need the silver keycard");
  33.                }
  34.             else if (world.worldtype == 1)
  35.                {
  36.                centerprint (activator, "You need the silver runekey");
  37.                }
  38.             else if (world.worldtype == 0)
  39.                {
  40.                centerprint (activator, "You need the silver key");
  41.                }
  42.             }
  43.          else
  44.             {
  45.             if (world.worldtype == 2)
  46.                {
  47.                centerprint (activator, "You need the gold keycard");
  48.                }
  49.             else if (world.worldtype == 1)
  50.                {
  51.                centerprint (activator, "You need the gold runekey");
  52.                }
  53.             else if (world.worldtype == 0)
  54.                {
  55.                centerprint (activator, "You need the gold key");
  56.                }
  57.             }
  58.          }
  59.       sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  60.       return;
  61.       }
  62.  
  63.    activator.items = activator.items - self.items;
  64.  
  65.    // we can't just remove (self) here, because this is a touch function
  66.    // called while C code is looping through area links...
  67.    self.touch = SUB_Null;
  68.    self.use = SUB_Null;
  69.    self.nextthink = time + 0.1;
  70.    self.think = SUB_Remove;
  71.    self.message = "";
  72.  
  73.    sound (self, CHAN_VOICE, self.noise4, 1, ATTN_NORM);
  74.  
  75.    SUB_UseTargets();
  76.    };
  77.  
  78. void() keytrigger_touch =
  79.    {
  80.    activator = other;
  81.    keytrigger_use();
  82.    };
  83.  
  84. /*QUAKED trigger_usekey (0 .5 0) ? USE_GOLD_KEY
  85. Variable sized single use trigger that requires a key to trigger targets.  Must be targeted at one or more entities.
  86.  
  87. "message" is printed when the trigger is touched without having the right key.
  88. */
  89.  
  90. void() trigger_usekey =
  91.     {
  92.    if (world.worldtype == 0)
  93.     {
  94.         precache_sound ("doors/medtry.wav");
  95.         precache_sound ("doors/meduse.wav");
  96.         self.noise3 = "doors/medtry.wav";
  97.         self.noise4 = "doors/meduse.wav";
  98.     }
  99.     else if (world.worldtype == 1)
  100.     {
  101.         precache_sound ("doors/runetry.wav");
  102.         precache_sound ("doors/runeuse.wav");
  103.         self.noise3 = "doors/runetry.wav";
  104.         self.noise4 = "doors/runeuse.wav";
  105.     }
  106.     else if (world.worldtype == 2)
  107.     {
  108.         precache_sound ("doors/basetry.wav");
  109.         precache_sound ("doors/baseuse.wav");
  110.         self.noise3 = "doors/basetry.wav";
  111.         self.noise4 = "doors/baseuse.wav";
  112.     }
  113.     else
  114.     {
  115.         dprint ("no worldtype set!\n");
  116.     }
  117.  
  118.    if (self.spawnflags & USE_GOLD_KEY)
  119.       self.items = IT_KEY2;
  120.    else
  121.       self.items = IT_KEY1;
  122.  
  123.    self.use = keytrigger_use;
  124.    self.touch = keytrigger_touch;
  125.  
  126.     InitTrigger ();
  127.    };
  128.  
  129. void() remove_touch =
  130.    {
  131.    if (other.flags & self.cnt)
  132.       return;
  133.    other.touch = SUB_Null;
  134.    other.model = "";
  135.    remove(self);
  136. //   other.nextthink = time + 0.1;
  137. //   other.think = SUB_Remove;
  138.    };
  139.  
  140. /*QUAKED trigger_remove (.5 .5 .5) ? ignoremonsters ignoreplayers
  141. Variable sized trigger that removes the thing
  142. that touches it.  Does not affect monsters or
  143. players.
  144. */
  145. void() trigger_remove =
  146.    {
  147.    self.cnt = FL_CLIENT|FL_MONSTER;
  148.    if (self.spawnflags & 1)
  149.       self.cnt = self.cnt - FL_MONSTER;
  150.    if (self.spawnflags & 2)
  151.       self.cnt = self.cnt - FL_CLIENT;
  152.    InitTrigger ();
  153.    self.touch = remove_touch;
  154.    };
  155. /*
  156. ==============================================================================
  157.  
  158. trigger_setgravity
  159.  
  160. ==============================================================================
  161. */
  162.  
  163. void() trigger_gravity_touch =
  164. {
  165.     if (other.classname != "player")
  166.         return;
  167.    if (self.gravity == -1)
  168.       other.gravity = 1.0;
  169.    else
  170.       other.gravity = self.gravity;
  171. };
  172.  
  173. /*QUAKED trigger_setgravity (.5 .5 .5) ?
  174. set the gravity of a player
  175. "gravity" what to set the players gravity to
  176.  - 0 (default) normal gravity
  177.  - 1 no gravity
  178.  - 2 almost no gravity
  179.  - ...
  180.  - 101 normal gravity
  181.  - 102 slightly higher gravity
  182.  - ...
  183.  - 1000 very high gravity
  184. */
  185. void() trigger_setgravity =
  186. {
  187.     InitTrigger ();
  188.    self.touch = trigger_gravity_touch;
  189.    if (!self.gravity)
  190.       {
  191.       self.gravity = -1;
  192.       }
  193.    else
  194.       {
  195.       self.gravity = ((self.gravity - 1) / 100);
  196.       }
  197. };
  198.  
  199. void() trigger_command_use =
  200.    {
  201.    if ( self.message )
  202.       localcmd( self.message );
  203.    };
  204.  
  205. /*QUAKED trigger_command (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
  206.  When triggered, stuffs a command into the console to allow map
  207.  designers to set server variables.
  208.  
  209.  "message" is the command to send to the console.
  210. */
  211.  
  212. void() trigger_command =
  213.    {
  214.    self.use = oncount_use;
  215.     self.think = SUB_Null;
  216.    };
  217.  
  218. void() trigger_decoy_touch =
  219.    {
  220.    if (other.classname != "monster_decoy")
  221.       return;
  222.    self.touch = SUB_Null;
  223.    self.nextthink = time + 0.1;
  224.    self.think = SUB_Remove;
  225.    SUB_UseTargets();
  226.    };
  227.  
  228. /*QUAKED trigger_decoy_use (.5 .5 .5) ?
  229.  only the decoy player can trigger this
  230.  once triggers, all targets are used
  231. */
  232.  
  233. void() trigger_decoy_use =
  234.    {
  235.    if (deathmatch)
  236.     {
  237.         remove(self);
  238.         return;
  239.     }
  240.    InitTrigger ();
  241.    self.touch = trigger_decoy_touch;
  242.    };
  243.  
  244. void() trigger_waterfall_touch =
  245.    {
  246.    // only affect players
  247.    if (!(other.flags & FL_CLIENT))
  248.       {
  249.       return;
  250.       }
  251.  
  252.    other.velocity = other.velocity + self.movedir;
  253.    other.velocity_x = other.velocity_x + self.count * ( random() - 0.5 );
  254.    other.velocity_y = other.velocity_y + self.count * ( random() - 0.5 );
  255.    };
  256.  
  257. /*QUAKED trigger_waterfall (.2 .5 .2) ?
  258.  Pushes the player in the direction specified by angles.
  259.  
  260.  "speed" is the strength of the push (default 50).
  261.  "count" amount of random xy movement to add to velocity (default 100).
  262. */
  263.  
  264. void() trigger_waterfall =
  265.    {
  266.    InitTrigger ();
  267.    self.touch = trigger_waterfall_touch;
  268.  
  269.    if ( self.count == 0 )
  270.       {
  271.       self.count = 100;
  272.       }
  273.  
  274.    if ( self.speed == 0 )
  275.       {
  276.       self.movedir = self.movedir * 50;
  277.       }
  278.    else
  279.       {
  280.       self.movedir = self.movedir * self.speed;
  281.       }
  282.    };
  283.